<template>
  <div>
    <el-dialog :modelValue="visiable" title="新增记录" width="500" @close="$emit('close')">
      <div class="content">
        <el-input v-model="content" :rows="8" type="textarea" placeholder="新进班组计划" />
      </div>
      <div class="btn">
        <el-button type="primary" @click="addLog">提交记录</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import useLog from '@renderer/composables/useLog'
import { ElMessage } from 'element-plus'
import { ref } from 'vue'

defineProps(['visiable'])
const emit = defineEmits(['close'])

const content = ref('')
const { add } = useLog()

const addLog = async () => {
  const reg = content.value.match(/\d{4}年\d{1,2}月\d{1,2}日/g)
  await add({
    date: reg![0],
    content: content.value,
  })
  content.value = ''
  ElMessage({
    message: '数据添加成功',
    type: 'success',
  })
  emit('close')
}
</script>

<style lang="scss" scoped>
.top {
  @apply flex justify-between items-center mb-2;
  .date {
  }
}
.btn {
  @apply mt-2 flex justify-end;
}
</style>
